//
//  EventAddView.m
//  lvtu
//
//  Created by martin on 12-9-2.
//
//

#import "EventAddView.h"

@implementation EventAddView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (id)initWithFrame:(CGRect)frame Type:(EventType)type
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        index = type;
        
        nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 40, 34, 12)];
        nameLabel.font = [UIFont systemFontOfSize:10];
        nameLabel.backgroundColor = [UIColor clearColor];
        nameLabel.textColor = [UIColor darkGrayColor];
        nameLabel.textAlignment = UITextAlignmentCenter;
        [self addSubview:nameLabel];
        
        button = [[UIButton alloc] initWithFrame:CGRectMake(5, 5, 34, 34)];
        if (type == EVENTTYPE_TRAVEL) {
            [button setImage:[UIImage imageNamed:@"btn_you_normal.png"] forState:UIControlStateNormal];
            [button setImage:[UIImage imageNamed:@"btn_you_press.png"] forState:UIControlStateHighlighted];
            nameLabel.text = @"游";
        }
        else if (type == EVENTTYPE_EAT)
        {
            [button setImage:[UIImage imageNamed:@"btn_chi_normal.png"] forState:UIControlStateNormal];
            [button setImage:[UIImage imageNamed:@"btn_chi_press.png"] forState:UIControlStateHighlighted];
            nameLabel.text = @"吃";
        }
        else if (type == EVENTTYPE_LIVE)
        {
            [button setImage:[UIImage imageNamed:@"btn_zhu_normal.png"] forState:UIControlStateNormal];
            [button setImage:[UIImage imageNamed:@"btn_zhu_press.png"] forState:UIControlStateHighlighted];
            nameLabel.text = @"住";
        }
        else if (type == EVENTTYPE_BUY)
        {
            [button setImage:[UIImage imageNamed:@"btn_gou_normal.png"] forState:UIControlStateNormal];
            [button setImage:[UIImage imageNamed:@"btn_gou_press.png"] forState:UIControlStateHighlighted];
            nameLabel.text = @"购";
        }
        else if (type == EVENTTYPE_PLAY)
        {
            [button setImage:[UIImage imageNamed:@"btn_yu_normal.png"] forState:UIControlStateNormal];
            [button setImage:[UIImage imageNamed:@"btn_yu_press.png"] forState:UIControlStateHighlighted];
            nameLabel.text = @"娱";
        }
        [button addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:button];
    }
    return self;
}

- (void)dealloc
{
    [button release];button = nil;
    [nameLabel release];nameLabel = nil;
    [super dealloc];
}

- (void)buttonPressed
{
    [delegate imageButtonTouchUpInside:index];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
